﻿namespace NTLib.Core.UTest.Manipulators
{
    using Core.Manipulators;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;

    [TestClass]
    public class SealedCollectionUTest
    {
        #region Fields

        private const string CATEGORY = "Core.Manipulator";

        #endregion

        #region Methods

        [TestCategory(CATEGORY)]
        [TestMethod]
        public void Sealed_SimpleSealedCollection()
        {
            string testStr = "poney";
            List<string> testers = new List<string>() { "toto", "toto2", testStr };
            UnsafeSealedCollection<string> collection = new UnsafeSealedCollection<string>();

            collection.Add(testStr);

            collection.Sealed();

            try
            {
                collection.Add("toto");
                Assert.Fail("should through an exception");
            }
            catch (Exception)
            {
            }

            try
            {
                collection.Insert(0, "toto");
                Assert.Fail("should through an exception");
            }
            catch (Exception)
            {
            }

            try
            {
                collection[0] = "toto";
                Assert.Fail("should through an exception");
            }
            catch (Exception)
            {
            }

            Assert.IsTrue(collection.Contains(testStr));
            Assert.AreEqual(testStr, collection[0]);
        }

        #endregion
    }
}
